#include<iostream>
#include<string>

using namespace std;

int n, m;
int ans = 0;
bool vis[105][105];
char mp[105][105];

void dfs(int x, int y) {
	if (x < 0 || x >= n || y < 0 || y >= m || mp[x][y] == '.' || vis[x][y]) {
		return;
	}
	vis[x][y] = true;
	dfs(x - 1, y);
	dfs(x + 1, y);
	dfs(x, y - 1);
	dfs(x, y + 1);
}

int main(void) {
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> mp[i]; 
	}
	cout << "--------------" << endl;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if(!vis[i][j] && mp[i][j] == '#') {
				dfs(i, j);
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
